package com.atguigu.tingshu.account.service;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.account.UserAccount;
import com.atguigu.tingshu.model.account.UserAccountDetail;
import com.atguigu.tingshu.vo.account.AccountLockResultVo;
import com.atguigu.tingshu.vo.account.AccountLockVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;

import java.math.BigDecimal;

public interface UserAccountService extends IService<UserAccount> {


    /**
     * 保存用户账户信息
     *
     * @param userAccount
     */
    void saveAccount(UserAccount userAccount);

    /**
     * 获取用户账户余额
     *
     * @return
     */
    BigDecimal getAvailableAmount();

    /**
     * 检查并锁定用户账户余额
     *
     * @param userAccountVo
     * @return
     */
    Result<AccountLockResultVo> checkAndLockAmount(AccountLockVo userAccountVo);

    /**
     * 保存账户流水到数据库
     *
     */
    void log(String content, Long userId, BigDecimal amount, String orderNo, String tradeType);

    /**
     * 分页查询用户充值记录
     * @param pageParam
     * @param userId
     * @return
     */
    IPage<UserAccountDetail> findUserRechargePage(IPage<UserAccountDetail> pageParam, Long userId);

    /**
     * 分页查询用户消费记录
     * @param pageParam
     * @param userId
     * @return
     */
    IPage<UserAccountDetail> findUserConsumePage(IPage<UserAccountDetail> pageParam, Long userId);
}
